package com.cat.dataStructure;

import java.util.HashMap;
import java.util.HashSet;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/number-of-pairs-of-interchangeable-rectangles/
 * @create 2025/8/13 17:12
 * @since JDK17
 */

public class Solution01 {
    static HashMap<Double, Integer> map = new HashMap<>();
    public long interchangeableRectangles(int[][] rectangles) {
        map.clear();
        long ans = 0;
        int n = rectangles.length, cnt;
        for (int i = 0; i < n; i++) {
            double x = ((double) rectangles[i][0]) / rectangles[i][1];
            cnt = map.getOrDefault(x, 0) + 1;
            map.put(x, cnt);
            ans += cnt - 1;
        }
        return ans;
    }
}
